<?php

/**
 * This is the model class for table "penyedia_travel".
 *
 * The followings are the available columns in table 'penyedia_travel':
 * @property integer $ID_TRAVEL
 * @property string $NAMA_TRAVEL
 * @property string $JENIS_TRAVEL
 * @property string $USERNAME_TRAVEL
 * @property string $PASSWORD
 * @property string $ALAMAT_TRAVEL
 * @property string $EMAIL
 * @property string $TELEPON_TRAVEL
 * @property string $DESKRIPSI_TRAVEL
 * @property string $CREATE_TIME
 * @property string $LAST_LOGIN
 * @property string $UPDATE_TIME
 *
 * The followings are the available model relations:
 * @property DetailPerjalananTravel[] $detailPerjalananTravels
 * @property FasilitasTravel[] $fasilitasTravels
 * @property LayananTravel[] $layananTravels
 * @property Promosi[] $promosis
 */
class PenyediaTravel extends GoesActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return PenyediaTravel the static model class
	 */
	 public $PASSWORD_repeat;
	 
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'penyedia_travel';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('NAMA_TRAVEL, USERNAME_TRAVEL, PASSWORD, PASSWORD_repeat', 'required'),
			array('NAMA_TRAVEL, TELEPON_TRAVEL', 'length', 'max'=>25),
			array('JENIS_TRAVEL, USERNAME_TRAVEL', 'length', 'max'=>20),
			array('PASSWORD, ALAMAT_TRAVEL, EMAIL', 'length', 'max'=>100),
			array('DESKRIPSI_TRAVEL', 'length', 'max'=>1000),
			array('CREATE_TIME, LAST_LOGIN, UPDATE_TIME', 'safe'),
			array('PASSWORD', 'compare'),
			array('PASSWORD_repeat', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_TRAVEL, NAMA_TRAVEL, JENIS_TRAVEL, USERNAME_TRAVEL, PASSWORD, ALAMAT_TRAVEL, EMAIL, TELEPON_TRAVEL, DESKRIPSI_TRAVEL, CREATE_TIME, LAST_LOGIN, UPDATE_TIME', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'detailPerjalananTravels' => array(self::HAS_MANY, 'DetailPerjalananTravel', 'ID_TRAVEL'),
			'fasilitasTravels' => array(self::HAS_MANY, 'FasilitasTravel', 'ID_TRAVEL'),
			'layananTravels' => array(self::HAS_MANY, 'LayananTravel', 'ID_TRAVEL'),
			'promosis' => array(self::HAS_MANY, 'Promosi', 'ID_TRAVEL'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_TRAVEL' => 'Id Travel',
			'NAMA_TRAVEL' => 'Nama Travel',
			'JENIS_TRAVEL' => 'Jenis Travel',
			'USERNAME_TRAVEL' => 'Username Travel',
			'PASSWORD' => 'Password',
			'ALAMAT_TRAVEL' => 'Alamat Travel',
			'EMAIL' => 'Email',
			'TELEPON_TRAVEL' => 'Telepon Travel',
			'DESKRIPSI_TRAVEL' => 'Deskripsi Travel',
			'CREATE_TIME' => 'Waktu User dibuat',
			'LAST_LOGIN' => 'Waktu Login Terakhir',
			'UPDATE_TIME' => 'Waktu Update',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_TRAVEL',$this->ID_TRAVEL);
		$criteria->compare('NAMA_TRAVEL',$this->NAMA_TRAVEL,true);
		$criteria->compare('JENIS_TRAVEL',$this->JENIS_TRAVEL,true);
		$criteria->compare('USERNAME_TRAVEL',$this->USERNAME_TRAVEL,true);
		$criteria->compare('PASSWORD',$this->PASSWORD,true);
		$criteria->compare('ALAMAT_TRAVEL',$this->ALAMAT_TRAVEL,true);
		$criteria->compare('EMAIL',$this->EMAIL,true);
		$criteria->compare('TELEPON_TRAVEL',$this->TELEPON_TRAVEL,true);
		$criteria->compare('DESKRIPSI_TRAVEL',$this->DESKRIPSI_TRAVEL,true);
		$criteria->compare('CREATE_TIME',$this->CREATE_TIME,true);
		$criteria->compare('LAST_LOGIN',$this->LAST_LOGIN,true);
		$criteria->compare('UPDATE_TIME',$this->UPDATE_TIME,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
	
	  protected function afterValidate()
	  {
		parent::afterValidate();
		//$this->PASSWORD= $this->encrypt($this->PASSWORD); 
		$this->PASSWORD= $this->PASSWORD;
	  }
	  /*
	  public function encrypt($value)
	  {
		return md5($value);
	  }
	  */
}